<template>
  <span style="overflow: auto;">
    <template v-if="!isDialog">
      <user-details-2 ref="userDetails2" />
    </template>
    <!--详情-->
    <template v-if="isDialog">
      <model-dialog :visible="recordDetailsShow" :title="title" :width="'23cm'" @close="recordDetailsShow=!recordDetailsShow">
        <template>
          <user-details-2 ref="userDetails2" />
        </template>
      </model-dialog>
    </template>
  </span>
</template>
<script>
import UserDetails2 from './UserDetails2.vue'
export default {
  components: { UserDetails2 },
  props: {
    isDialog: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      recordDetailsShow: false,
      title: ''
    }
  },
  methods: {
    async init(id) {
      var res = await this.$store.dispatch('getUserById', id)
      if (this.isDialog) {
        this.title = `[${res.realName}]人员详情`
        this.recordDetailsShow = true
      }
      this.$nextTick(() => {
        this.$refs.userDetails2.init(res)
      })
    }
  }
}
</script>
